package com.gin.no_gay_alliance.database.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.gin.no_gay_alliance.database.entity.ReplyHistoryTopic;

import java.util.List;

/**
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/16 15:21
 **/
@Dao
public interface ReplyHistoryTopicDao {
    /**
     * 添加一个观察主题
     *
     * @param replyHistoryTopic 观察主题
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void add(ReplyHistoryTopic replyHistoryTopic);

    /**
     * 按主题id查询观察主题
     *
     * @param topicId 主题id
     * @return 观察主题
     */
    @Query("SELECT * FROM ReplyHistoryTopic WHERE topicId=:topicId")
    ReplyHistoryTopic get(long topicId);

    /**
     * 查询所有观察主题
     *
     * @return 所有观察主题
     */
    @Query("SELECT * FROM ReplyHistoryTopic")
    List<ReplyHistoryTopic> listAll();

    /**
     * 移除一个观察主题
     *
     * @param topicId 主题id
     */
    @Query("DELETE FROM ReplyHistoryTopic WHERE topicId=:topicId")
    void remove(long topicId);
}
